set(TARGET_NAME ${SHADER_COMPILE_TARGET})

file(GLOB_RECURSE SHADER_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.vert"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.frag"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.comp"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.geom"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.tesc"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.tese"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.mesh"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.task"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.rgen"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.rchit"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.rmiss"
                                            "${CMAKE_CURRENT_SOURCE_DIR}/hlsl/*.rcall")

SOURCE_GROUP("shaders" FILES ${SHADER_FILES})

set(SHADER_INCLUDE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/include)

set(GENERATED_SHADER_FOLDER "generated")
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATED_SHADER_FOLDER})
  file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${GENERATED_SHADER_FOLDER})
endif()

include(${MOYU2_ROOT_DIR}/cmake/ShaderCompile.cmake)

compile_shader(
  "${SHADER_FILES}"
  "${TARGET_NAME}"
  "${SHADER_INCLUDE_FOLDER}"
  "${GENERATED_SHADER_FOLDER}"
  "${glslangValidator_executable}")

set_target_properties("${TARGET_NAME}" PROPERTIES FOLDER "Engine" )
